package com.kaifamiao.annotation;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
@Aspect
@Order(3)
public class TimeAspect {

    @Before("execution(* com.kaifamiao.annotation.TigerService.*(..))")
    public void before( JoinPoint jp ) {
        String name = jp.getSignature().getName();
        System.out.println( name + " - " + LocalDateTime.now() );
    }

    @After("execution(* com.kaifamiao.annotation.TigerService.*(..))")
    public void after( JoinPoint jp ) {
        String name = jp.getSignature().getName();
        System.out.println( name + " - " + LocalDateTime.now() );
    }

}
